package client;

import java.awt.BorderLayout;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;

import server.BkMngITF;
import server.BkStfITF;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import client.Configuration;

public class BkCheckStaffGUI extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	
	Configuration config=new Configuration();
	String rmiAddress=config.getRmiAddress();
	BkMngITF Mitf;
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BkCheckStaffGUI frame = new BkCheckStaffGUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BkCheckStaffGUI() {
		setTitle("\u5728\u804C\u5458\u5DE5\u7BA1\u7406");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton button_1 = new JButton("\u53D1\u653E\u5DE5\u8D44");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					Mitf = (BkMngITF) Naming.lookup(rmiAddress+"BankManager");
					
					String sSalary = JOptionPane.showInputDialog("�����빤�ʶ"); 
					double salary=Double.parseDouble(sSalary);
					int pID=001;//�ӱ?�ж�ȡ
					if(Mitf.paySalary(pID,salary)==1)
						JOptionPane.showMessageDialog(null, "��������������������롣");
					else
						JOptionPane.showMessageDialog(null, "�����ѷ��ţ�");
					
				} catch (MalformedURLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (RemoteException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (NotBoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		button_1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
		button_1.setBounds(153, 59, 113, 47);
		contentPane.add(button_1);
		
		JButton button_2 = new JButton("\u89E3\u8058");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {

				try {
					Mitf = (BkMngITF) Naming.lookup(rmiAddress+"BankManager");
					int pID=001;//�ӱ?ѡ��
					Mitf.fire(pID);
				} catch (RemoteException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (MalformedURLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (NotBoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		button_2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
		button_2.setBounds(153, 116, 113, 47);
		contentPane.add(button_2);
		
		JButton button_3 = new JButton("\u8FD4\u56DE");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BkManagerWorkGUI frame = new BkManagerWorkGUI();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
				dispose();
			}
		});
		button_3.setFont(new Font("΢���ź�", Font.PLAIN, 13));
		button_3.setBounds(341, 9, 83, 22);
		contentPane.add(button_3);
	}
}
